<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0"
    />
    <meta
      http-equiv="X-UA-Compatible"
      content="ie=edge"
    />
    <title>Document</title>
  </head>

  <body>
    <script>
      var obj = {
        a: 1,
        b: 2,
        [Symbol.iterator]() {
          const keys = Object.keys(this);
          let i = 0;
          return {
            next: () => {
              const propName = keys[i];
              const propValue = this[propName];
              const result = {
                // value: {
                //   propName,
                //   propValue,
                // },
                value: propValue,
                done: i >= keys.length,
              };
              i++;
              return result;
            },
          };
        },
      };

      const arr = [...obj];
      console.log(arr);

      // function test(a, b) {
      //     console.log(a, b)
      // }

      // test(...obj);
    </script>
  </body>
</html>
